#pragma once


#include"HashTable.h"

namespace yyh
{
	template<class K, class Hash = HashFunc<K>>
	class unordered_set
	{
		struct SetKeyOft
		{
			const K& operator()(const K& key)
			{
				return key;
			}
		};
	public:
		typedef typename HashTable<K, const K, SetKeyOft, Hash>::Iterator iterator;
		typedef typename HashTable<K, const K, SetKeyOft, Hash>::ConstIterator const_iterator;

		iterator begin()
		{
			return _ht.Begin();
		}

		iterator end()
		{
			return _ht.End();
		}

		const_iterator begin() const
		{
			return _ht.Begin();
		}

		const_iterator end() const
		{
			return _ht.End();
		}

		pair<iterator, bool> insert(const K& key)
		{
			return _ht.Insert(key);
		}

	private:
		HashTable<K, const K, SetKeyOft, Hash> _ht;
	};

	void Print(const unordered_set<int>& tree)
	{
		unordered_set<int>::const_iterator it = tree.begin();
		while (it != tree.end())
		{
			cout << *it << ' ';
			++it;
		}
		cout << endl;
	}

	void set_test1()
	{
		int arr[] = { 19,30,5,36,13,20,21,12,58,111 };
		unordered_set<int> tree;
		for (auto& e : arr)
		{
			tree.insert(e);
		}
		for (auto& e : tree)
		{
			cout << e << ' ';
		}
		cout << endl;
		Print(tree);
	}
}